﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SwimmingCompetition
{
    public partial class EventWizard : Form
    {
        public string Grammar { get; set; }
        public EventWizard()
        {
            InitializeComponent();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            /*
            date : 15/09/09
            { ... }*/
            _richTextBoxP.Text += "date :";
            _richTextBoxP.Text += _dateTimePickerP.Value.Date.ToShortDateString() + "{\n}";
            _richTextBoxP.SelectionStart = _richTextBoxP.TextLength - 1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            _tabControl.SelectedIndex = _tabControl.SelectedIndex + 1;
        }

        private void EventWizard_FormClosing(object sender, FormClosingEventArgs e)
        {
            ConstructPhrase();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            ConstructPhrase();
            this.Close();
        }

        private void ConstructPhrase()
        {
            Grammar += "event {\n\t ";

            Grammar += "infoevent{\n\t\tnameevent : \"" + textBoxName.Text
                    + "\"\n\t\tcat : " + comboBoxCategoryEvent.Text
                    + "\n\t\torg : \"" + textBoxOrg.Text
                    + "\" \n\t\tloc : \"" + textBoxLoc.Text
                    + "\" \n\t\ttype : \"" + textBoxType.Text
                    + "\" \n\t\tstart : " + dateTimePickerSD.Value.ToShortDateString()
                    + "\n\t\tend : " + dateTimePickerED.Value.ToShortDateString()
                    + "\n\t\tendreg : " + dateTimePickerERegD.Value.ToShortDateString()
                    + "\n\t\tpoolbase : " + maskedTextBoxPool.Text + " m"
                    + "\n\t\tlimittime : \"" + comboBoxLimit.Text
                    + "\" \n\t\tlanes : " + maskedTextBoxLane.Text
                    + "\n\t}";

            Grammar += "\n\tjury{\n\t\treferee : \"" + textBoxReferee.Text
                + "\" \n\t\tcoadjutor : \"" + textBoxCoadjuctor.Text
                + "\" \n\t\tdepjudge : \"" + textBoxDepj.Text
                + "\" \n\t\tfsemployee : \"" + textBoxFSE.Text
                + "\" \n\t\tcompetemployee: \"" + textBoxCE.Text
                + "\"\n\t}\n";

            Grammar += "\n\ttiming{\n\t\tcronotype : \"" + comboBoxCronoType.Text
                + "\" \n\t\tcronoserv : \"" + textBoxCronoServ.Text
                + "\" \n\t\tcronosociety : \"" + textBoxCronoSoc.Text
                + "\"}\n";

            Grammar += "\n\tother{\n\t\tspeaker: \"" + textBoxSpeak.Text
                + "\" \n\t\tdoctor: \"" + textBoxDoct.Text
                + "\" \n\t\tmanager: \"" + textBoxMAn.Text
                + "\"}\n";

            Grammar += "\n\tprogram{\n\t\t" + _richTextBoxP.Text + "}\n";

            Grammar += "\n\tstartlist{\n\t\t" + richTextBoxS.Text + "}\n";
            
            Grammar += "\n\tnotes : \"" + richTextBoxNote.Text + "\"";

            Grammar += "\n}";
        }

        private void button9_Click(object sender, EventArgs e)
        {
            /*
           [ hour : 12:00
            category : Senior
            speciality : "50 rana"
            turn : heats ]
            */
            string s = "\n\t\t\t[ hour : " + maskedTextBoxHour.Text
                + "\n\t\t\tcategory : " + comboBoxPCat.Text
                + "\n\t\t\tspeciality : \"" + textBoxPSpec.Text
                + "\"\n\t\t\tturn : " + comboBoxPType.Text
                +"]";
            _richTextBoxP.Text = _richTextBoxP.Text.Insert(_richTextBoxP.TextLength-2,s);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            /*
              compname : "50 rana"
             {
               ...
            }
             * */
            richTextBoxS.Text += "\n\t\tcompname : \"" + textBoxComSName.Text
                + "\"\n\t\t{ \n\t\t}";
        }

        private void button11_Click(object sender, EventArgs e)
        {
            /* ...
            heats 1
            {
            ...
            }
             * */
            string s = comboBoxNameTurn.Text + textBoxNumberTurn.Text + "{\n\t\t}";
            richTextBoxS.Text = richTextBoxS.Text.Insert(richTextBoxS.TextLength - 4, s);
        }

        private void button12_Click(object sender, EventArgs e)
        {
            /*[
            lane : 1
            acode :"VEN00"
            aname : "name"
            asurname :"surname"
            asociety: "asociety"
            abirthday : 12/06/1990
            atimereg: 00:02:01:07
            atimeres: 00:00:00:00
            ]*/
            string s = "[ lane : " + textBoxALane.Text
                + "\n\t\tacode : \"" + textBoxACode.Text
                + "\"\n\t\taname : \"" + textBoxAName.Text
                + "\"\n\t\tasurname : \"" + textBoxASur.Text
                + "\"\n\t\tasociety: \"" + textBoxASoc.Text
                + "\"\n\t\tabirthday : " + maskedTextBoxABirth.Text
                + "\n\t\tatimereg: " + maskedTextBoxATimeReg.Text
                + "\n\t\tatimeres: " + maskedTextBoxATimeRes.Text
                + "\n]\n";
            richTextBoxS.Text = richTextBoxS.Text.Insert(richTextBoxS.TextLength - 8, s);
        }
    }
}
